#include "msg.h"
#include "ui_msg.h"

Msg::Msg(QString msg, QString othername, QPixmap img,  QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Msg)
{
    ui->setupUi(this);
    _msg = msg;
    _othername = othername;
    _img = img;

    ui->username->setText(_othername);
    ui->textBrowser->setText(_msg);
    // 插入图像
    QPixmap scaledImg = img.scaled(ui->usericon->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
    // 在 QLabel 中显示图像
    ui->usericon->setPixmap(scaledImg);
    ui->usericon->setScaledContents(true);

}

Msg::~Msg()
{
    delete ui;
}
